<include file="public@storage"/>
</head>
<body>

<div class="container body-content" style="margin-top:20px; width: 100%">
    <div class="panel panel-info" style="margin-bottom: 0.5rem">
        <div class="panel-heading"><span id="storageName">{$storageInfo[0]['name']}</span>容器详情</div>
        <input type="hidden" id="storageUuid" value="{$storageInfo[0]['uuid']}">
        <div class="panel-body">
            <div class="row">
                <div class="col-sm-12">
                    <div id="toolbar" class="btn-group">
                        <select id="selectStorage" class="btn btn-info" style="margin-left: 5px; width: 10rem"
                                onchange="changeStorage()">
                            <option value="">请选择仓库</option>
                            <volist id="uuid" name="storageInfo" id="value">
                                <option value="{$value['uuid']}">{$value['name']}</option>
                            </volist>
                        </select>
                        <!-- 按钮触发模态框 -->
                    </div>
                    <table id="table"></table>

                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script src="__STATIC__/storage/js/common/selectStorage.js"></script>
<script>
    var storageUuid = $("#storageUuid").val();
    $(function () {
        if ($("#storageUuid").val() === '') {
            $("#selectStorage").show();
        } else {
            $("#selectStorage").hide();
        }
        init();
    });

    function init() {
        var url = "{:url('Query/queryContainer')}?storageUuid=" + storageUuid;
        var columns = [
            {
                title: '序号',
                width: 50,
                align: "center",
                valign: 'middle',
                formatter: function (value, row, index) {
                    return index + 1;
                }
            },
            {
                title: '容器号',
                field: 'container_code',
                align: "center",
                valign: 'middle',
                filter: {
                    type: 'input'
                }
            },
            {
                title: '存放种类',
                field: 'type_count',
                align: "center",
                valign: 'middle',
                filter: {

                    type: 'input'
                }
            },
            {
                title: '存放件数',
                field: 'reel_count',
                align: "center",
                valign: 'middle',
                filter: {
                    type: 'input'
                }
            },
            {
                title: '存放站位',
                field: 'seat_code',
                align: "center",
                valign: 'middle',
                filter: {
                    type: 'input'
                }
            },
            {
                title: '存放仓库',
                field: 'name',
                align: "center",
                valign: 'middle',
                filter: {
                    type: 'input'
                }
            },
            {
                title: '是否上架',
                field: 'status',
                align: "center",
                valign: 'middle',
                width: 200,
                filter: {
                    type: 'select',
                    data: [{id: '', text: ''}, {id: 0, text: '未上架'}, {id: 1, text: '已上架'}]
                },
                formatter: function (value, row, index) {
                    var html = '';
                    if (value === 0 || value == null) {
                        html = '未上架';
                    } else {
                        html = '已上架';
                    }
                    return html;
                }
            },
        ];
        initTable(url, columns, 'server', InitSubTable);
        setColumn();
    }

    InitSubTable = function (index, row, $detail) {
        var tableId = "cur_table_"+index;
        $detail.html('<table id="'+ tableId+ '"></table>').find('table');

        var containerCode = row.container_code;
        var url = "{:url('Query/queryContainerDetail')}?containerCode=" + containerCode;
        var column = [
            {
                title: '序号', width: 50, align: "center", formatter: function (value, row, index) {
                    return index + 1;
                }
            },
            {
                title: '物料号',
                field: 'sub_materiel_id',
                align: "center",
                valign: 'middle',
            },
            {
                title: '条码',
                field: 'reel_id',
                align: "center",
                valign: 'middle',
            },
            {
                title: '数量',
                field: 'count',
                align: "center",
                valign: 'middle',
            },
            {
                title: '时间',
                field: 'time',
                align: "center",
                valign: 'middle',
            }
        ];
        initSubTable(tableId,url, column, 'client',true);
    };

</script>
</html>